<?php
namespace app\shop\controller;
use app\AdminRest;
use think\App;
use think\Request;
use app\shop\model\AdminShopBanner as ShopBannerModel;
use app\shop\model\AdminCompany;
class AdminShopBanner extends AdminRest
{

    protected $model;
    protected $company_model;
    public function __construct(App $app) {
        parent::__construct($app);
        $this->model         = new ShopBannerModel();
        $this->company_model = new AdminCompany();
    }



    /**
     * 获取商城轮播图
     */
    public function bannerList(){
        //$dis['uniacid'] = $this->_uniacid;
      	//敬水仙 2019年10月12日22:48:24
        $dis[] =  ['uniacid' ,'=' ,$this->_uniacid];
        $dis[] = ['status' , '<>' , -1 ];
        $page = $this->_input['limit'];
        $data = $this->model->bannerList($dis,$page);
        return $this->success($data);
    }

    /**
     *
     * 修改商城轮播图
     */

    public function bannerAdd(){
        $data = $this->_input;
        $data['uniacid'] = $this->_uniacid;
        $data['img']     = implode(',',$data['img']);
        $res  = $this->model->bannerAdd($data);
        return $this->success($res);
    }

    /**
     *
     * 删除商城轮播图
     */

    public function bannerDel(){
        $dis['id'] = $this->_input['id'];
        $res       = $this->model->bannerDel($dis);
        return $this->success($res);

    }
    /**
     *
     * 修改商城轮播图
     */
    public function bannerUpdate(){
        $input     = $this->_input;
        $dis['id'] = $input['id'];
        $res       = $this->model->bannerInfo($dis);
        if(count($input)>1){
            if(!empty($input['img'])){
                $input['img'] = implode(',',$input['img']);
            }
            $res = $this->model->bannerUpdate($dis,$input);
        }
        return $this->success($res);
    }

    /**
     * User: chenniang
     * Date: 2019-09-11 11:10
     * @return void
     * descption:获取公司
     */
    public function getCompany(){
        $dis[] = ['uniacid','=',$this->_uniacid];
        $data  = $this->company_model->companySelect($dis);
        return $this->success($data);
    }


}
